/*
*    Phantom v2.0 GUI Automation Software
*    Copyright (C) 2009  John C. Van Arsdall (john@phantomtest.com)
*
*    This program is free software; you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation; either version 2 of the License, or
*    (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License along
*    with this program; if not, write to the Free Software Foundation, Inc.,
*    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
// Status.h: interface for the CStatus class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_STATUS_H__B22196A7_9336_47C1_A59F_3EDB5104FA49__INCLUDED_)
#define AFX_STATUS_H__B22196A7_9336_47C1_A59F_3EDB5104FA49__INCLUDED_


#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "ssi_defines.h"
#include "ssi_string.h"	// Added by ClassView


#define sERROR    0
#define sOK       1
#define sWARNING  2
#define sSUCCESS  3
#define sFAIL     4

// None of these will increase the error count
#define STAT_ERR CStatus::MakeDefaultError(__LINE__, __FILE__) //CStatus(sERROR, __stat_err_string__, 0)///String __stat_err_string__; __stat_err_string__.Format("Internal Error: %d in %s", __LINE__, __FILE__); CStatus(sERROR, __stat_err_string__, 0)
#define STAT_OK CStatus(sOK, String("OK"), 0)
#define STAT_WARN CStatus(sWARNING, String("Warning"), 0)
#define STAT_SUCCESS CStatus(sSUCCESS, String("Success"), 0)
#define STAT_FAIL CStatus::MakeDefaultFailure(__LINE__, __FILE__)

#define ERR_NO_END_TOKEN CStatus(sERROR, "Missing semi-colon (;)")


class SSI_SCRIPTDLL_API CStatus  
{
public:

	CStatus& Format(SSI_BYTE inState, const SSI_CHAR *fmt, ...);

	void IncrementCounts();
	SSI_BYTE GetState();
	void Set(SSI_BYTE NewState, const String& NewMessage);
	static SSI_INT64 GetWarnCount();
	static SSI_INT64 GetErrCount();

  CStatus();
	// Added the bDoIncr so statements like Ret == STAT_ERR dont increase error count...
  CStatus(SSI_BYTE NewState, const String& NewMessage, const SSI_CHAR bDoIncr = 1);

  SSI_BOOL operator ==(CStatus Other);
  //CStatus& operator=(CStatus& Other);
	CStatus& operator=(CStatus Other);
  operator SSI_BOOL();
  virtual ~CStatus();

protected:
private:
 	String Message;
	SSI_BYTE State;
  static SSI_INT64 ErrCount;
  static SSI_INT64 WarnCount;
public:
	static CStatus MakeStatus(void);
	String GetStatusMessage(void);
	static CStatus MakeDefaultError(int LineNum, char* File);
	static CStatus MakeDefaultFailure(int LineNum, char* File);
};

#endif // !defined(AFX_STATUS_H__B22196A7_9336_47C1_A59F_3EDB5104FA49__INCLUDED_)



